<template>
  <div></div>
</template>
<script>
export default { name: 'LoginAuth' }
</script>
<script setup>
import { useRoute } from 'vue-router'
import { useAuthStore } from '@/stores/modules/auth.js'

const route = useRoute()
const authStore = useAuthStore()

/**清除之前的记录 */
authStore.cleanAuthInfo()

authStore.auth_token = route.query.auth_token
authStore.getUserInfo().then(async () => {
  // 设置权限过期时间
  authStore.setExperTime()

  //获取专家信息
  if (authStore.isExpert && authStore.userInfo.expertId) {
    await authStore.setExpertInfo()
  }
  if (route.query.return_url) {
    /**跳转回之前的页面 */
    window.open(route.query.return_url, '_self')
  } else {
    window.open('/', '_self')
  }
}).catch(() => {
  authStore.cleanAuthInfo()
})

</script>
<style lang='scss' scoped></style>